import requests from "./ajax";
import mockRequests from "./mockAjax";

/**
 * @desc 获取三级菜单数据
 */
export const reqgetCategoryList = () =>
  requests.get("/product/getBaseCategoryList");

/**
 * @desc 获取首页轮播图数据
 */
export const reqGetBannerList = () => mockRequests.get("/banner");

/**
 * @desc 登录
 */
export const reqUserLogin = (data) =>
  requests({
    url: "/user/passport/login",
    method: "POST",
    data,
  });
/**
 * @desc 获取验证码
 */
export const reqGetCode = (phone) =>
  requests({
    url: `/user/passport/sendCode/${phone}`,
    method: "GET",
  });
/**
 * @desc 注册
 */
export const reqUserRegister = (data) =>
  requests({
    url: "/user/passport/register",
    method: "POST",
    data,
  });

/**
 * @desc 获取用户信息
 */
export const reqUserInfo = () =>
  requests({
    url: "/user/passport/auth/getUserInfo",
    method: "GET",
  });

/**
 * @desc 退出登录
 */
export const reqLogout = () =>
  requests({
    url: "/user/passport/logout",
    method: "GET",
  });

/**
 * @desc 搜索
 */
export const reqGetSearchInfo = (data) =>
  requests({
    url: "/list",
    method: "POST",
    data,
  });


/**
 * @desc 商品详情
 */
export const reqGoodsInfo = (skuId) => 
  requests({
    url: `/item/${skuId}`,
    method: 'GET'
  })

/**
 * @desc 添加购物车
 */
export const reqAddToCart = (skuId, skuNum) => 
requests({
  url: `/cart/addToCart/${skuId}/${skuNum}`,
  method: 'POST'
})

/**
 * @desc 购物车列表
 */
 export const reqCartList = () => 
 requests({
   url: '/cart/cartList',
   method: 'GET'
 })

/**
 * @desc 删除购物车产品
 */
 export const reqDeleteCartById = (skuId) => 
 requests({
   url: `/cart/deleteCart/${skuId}`,
   method: 'DELETE'
 }) 

/**
 * @desc 修改购物车商品的选中状态
 */
 export const reqUpdateCheckedById = (skuId, isChecked) => 
 requests({
   url: `/cart/checkCart/${skuId}/${isChecked}`,
   method: 'GET'
 }) 

/**
 * @desc 获取用户地址信息
 */
 export const reqAddressInfo = () => 
 requests({
   url: '/user/userAddress/auth/findUserAddressList',
   method: 'GET'
 })

/**
 * @desc 获取商品清单
 */
 export const reqOrderInfo = () => 
 requests({
   url: '/order/auth/trade',
   method: 'GET'
 })


/**
 * @desc 提交订单
 */
 export const reqSubmitOrder = (tradeNo, data) => 
 requests({
   url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
   data,
   method: 'POST'
 })

/**
 * @desc 获取支付信息
 */
 export const reqPayInfo = ( orderId ) => 
 requests({
   url: `/payment/weixin/createNative/${orderId}`,
   method: 'GET'
 })

 /**
 * @desc 获取支付状态
 */
  export const reqPayStatus = ( orderId ) => 
  requests({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: 'GET'
  })

/**
 * @desc 获取我的订单
 */
 export const reqMyOrderList = ( page, limit ) => 
 requests({
   url: `/order/auth/${page}/${limit}`,
   method: 'GET'
 })